Forum : How to write messages to the screen without using "document.write()"?
Brief description  about Online courses   join in Online courses
View Sheetal  Panday 's Profile

How to write messages to the screen without using "document.write()"?

Hi,
how to write messages to the screen without using "document.write()"?
Asked by Sheetal Panday | Nov 27, 2009 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
hi sheetal,

Changing the contents of an element is a much better solution. When the method showStatus is invoked it will change the content of the span.

function showStatus(message) {
var element = document.getElementById("mystatus");
element.textContent = message; //for Firefox
element.innerHTML = message; //for IE (why can't we all just get along?)
return true;
}
<span id="mystatus">Test. </span>

Nov 27, 2009